/*
 * File:   RoutePlanner.h
 * Author: Thomas Trojer
 *
 * Created on 12. Juli 2010, 21:50
 */

#ifndef ROUTEPLANNER_H
#define	ROUTEPLANNER_H

#include <stdio.h>
#include <list>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <string>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <sstream>
#include <algorithm>

using std::string;
using std::ostringstream;
using std::tr1::unordered_map;
using std::tr1::unordered_set;
using std::list;

typedef struct rule {
    string condition;
    string body;
} Rule, Define;

class RoutePlanner {
public:
    RoutePlanner();
    virtual ~RoutePlanner();

    /* rules which go through the parser */
        void rule(string arule);
        void define(Define def);
        void ignore(string var);

        /* runtime planner functions */
        void prepare(string &meal);
        void rule(char token, Rule theRule);
        string plan(char token, float parameter[], int size = 0);
        string duplicate(char token, float parameter[], int size = 0);
        bool eval(string condition);

private:
        typedef list<Rule> RuleList;

        unordered_map<char, RuleList> rules;
        list<Define> defines;
        list<string> ignores;

        void trimString(string str);
        void replaceVars(string &str, float parameter[], int size);
};

#endif	/* ROUTEPLANNER_H */

